﻿using System;
using System.Reflection;
using System.Configuration;
using Maticsoft.Common;
using TKFA.IDAL;
using System.Web;
namespace TKFA.DALFactory
{
	/// <summary>
	/// 抽象工厂模式创建DAL。
	/// web.config 需要加入配置：(利用工厂模式+反射机制+缓存机制,实现动态创建不同的数据层对象接口) 
	/// DataCache类在导出代码的文件夹里
	/// <appSettings> 
	/// <add key="DAL" value="TKFA.OracleDAL" /> (这里的命名空间根据实际情况更改为自己项目的命名空间)
	/// </appSettings> 
	/// </summary>
	public sealed class DataAccess//<t>
	{
		private static readonly string AssemblyPath = ConfigurationManager.AppSettings["DAL"];
        private static readonly string Namespace = ConfigurationManager.AppSettings["SPACEDAL"];
		/// <summary>
		/// 创建对象或从缓存获取
		/// </summary>
		public static object CreateObject(string AssemblyPath,string ClassNamespace)
		{
			object objType = DataCache.GetCache(ClassNamespace);//从缓存读取
			if (objType == null)
			{
				try
				{
                    objType = Assembly.Load(AssemblyPath).CreateInstance(ClassNamespace);//反射创建
                    DataCache.SetCache(ClassNamespace, objType);// 写入缓存
				}
				catch
				{}
			}
			return objType;
		}
		/// <summary>
		/// 创建数据层接口
		/// </summary>
		//public static t Create(string ClassName)
		//{
			//string ClassNamespace = AssemblyPath +"."+ ClassName;
			//object objType = CreateObject(AssemblyPath, ClassNamespace);
			//return (t)objType;
		//}
		/// <summary>
		/// 创建DEPARTMENT数据层接口。部门表
		/// </summary>
		public static TKFA.IDAL.IDEPARTMENT CreateDEPARTMENT()
		{

            string ClassNamespace = Namespace + ".DEPARTMENT";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IDEPARTMENT)objType;
		}


		/// <summary>
		/// 创建FA_USERPOWER数据层接口。
		/// </summary>
		public static TKFA.IDAL.IFA_USERPOWER CreateFA_USERPOWER()
		{

			string ClassNamespace = Namespace +".FA_USERPOWER";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_USERPOWER)objType;
		}

		/// <summary>
		/// 创建FA_USER数据层接口。用户表
		/// </summary>
		public static TKFA.IDAL.IFA_USER CreateFA_USER()
		{

			string ClassNamespace = Namespace +".FA_USER";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_USER)objType;
		}

		/// <summary>
		/// 创建FA_STATUS_PROPERTY数据层接口。固定资产使用状态表
		/// </summary>
		public static TKFA.IDAL.IFA_STATUS_PROPERTY CreateFA_STATUS_PROPERTY()
		{

			string ClassNamespace = Namespace +".FA_STATUS_PROPERTY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_STATUS_PROPERTY)objType;
		}

		/// <summary>
		/// 创建FA_REPORT_MAIN数据层接口。固资报表
		/// </summary>
		public static TKFA.IDAL.IFA_REPORT_MAIN CreateFA_REPORT_MAIN()
		{

			string ClassNamespace = Namespace +".FA_REPORT_MAIN";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_REPORT_MAIN)objType;
		}

		/// <summary>
		/// 创建FA_REPORT_INS数据层接口。固资报表实例主
		/// </summary>
		public static TKFA.IDAL.IFA_REPORT_INS CreateFA_REPORT_INS()
		{

			string ClassNamespace = Namespace +".FA_REPORT_INS";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_REPORT_INS)objType;
		}

		/// <summary>
		/// 创建FA_REPORT_DATA数据层接口。固资报表实例数据
		/// </summary>
		public static TKFA.IDAL.IFA_REPORT_DATA CreateFA_REPORT_DATA()
		{

			string ClassNamespace = Namespace +".FA_REPORT_DATA";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_REPORT_DATA)objType;
		}

		/// <summary>
		/// 创建FA_PURCHASEVALUE数据层接口。购置值表
		/// </summary>
		public static TKFA.IDAL.IFA_PURCHASEVALUE CreateFA_PURCHASEVALUE()
		{

			string ClassNamespace = Namespace +".FA_PURCHASEVALUE";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_PURCHASEVALUE)objType;
		}

		/// <summary>
		/// 创建FA_PURCHASEPLAN数据层接口。购置计划
		/// </summary>
		public static TKFA.IDAL.IFA_PURCHASEPLAN CreateFA_PURCHASEPLAN()
		{

			string ClassNamespace = Namespace +".FA_PURCHASEPLAN";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_PURCHASEPLAN)objType;
		}

		/// <summary>
		/// 创建FA_PURCHASEDATA数据层接口。设备购置表
		/// </summary>
		public static TKFA.IDAL.IFA_PURCHASEDATA CreateFA_PURCHASEDATA()
		{

			string ClassNamespace = Namespace +".FA_PURCHASEDATA";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_PURCHASEDATA)objType;
		}

		/// <summary>
		/// 创建FA_PROPERTY数据层接口。属性参数表
		/// </summary>
		public static TKFA.IDAL.IFA_PROPERTY CreateFA_PROPERTY()
		{

			string ClassNamespace = Namespace +".FA_PROPERTY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_PROPERTY)objType;
		}

		/// <summary>
		/// 创建FA_MASTERDATA_EXCEL_PROPERTY数据层接口。
		/// </summary>
		public static TKFA.IDAL.IFA_MASTERDATA_EXCEL_PROPERTY CreateFA_MASTERDATA_EXCEL_PROPERTY()
		{

			string ClassNamespace = Namespace +".FA_MASTERDATA_EXCEL_PROPERTY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_MASTERDATA_EXCEL_PROPERTY)objType;
		}

		/// <summary>
		/// 创建FA_MASTERDATA_EXCEL_JW数据层接口。
		/// </summary>
		public static TKFA.IDAL.IFA_MASTERDATA_EXCEL_JW CreateFA_MASTERDATA_EXCEL_JW()
		{

			string ClassNamespace = Namespace +".FA_MASTERDATA_EXCEL_JW";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_MASTERDATA_EXCEL_JW)objType;
		}

		/// <summary>
		/// 创建FA_MASTERDATA_EXCEL数据层接口。
		/// </summary>
		public static TKFA.IDAL.IFA_MASTERDATA_EXCEL CreateFA_MASTERDATA_EXCEL()
		{

			string ClassNamespace = Namespace +".FA_MASTERDATA_EXCEL";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_MASTERDATA_EXCEL)objType;
		}

		/// <summary>
		/// 创建FA_MASTERDATA数据层接口。固定资产卡片
		/// </summary>
		public static TKFA.IDAL.IFA_MASTERDATA CreateFA_MASTERDATA()
		{

			string ClassNamespace = Namespace +".FA_MASTERDATA";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_MASTERDATA)objType;
		}

		/// <summary>
		/// 创建FA_DEVICECLASS_PROPERTY数据层接口。设备分类
		/// </summary>
		public static TKFA.IDAL.IFA_DEVICECLASS_PROPERTY CreateFA_DEVICECLASS_PROPERTY()
		{

			string ClassNamespace = Namespace +".FA_DEVICECLASS_PROPERTY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_DEVICECLASS_PROPERTY)objType;
		}

		/// <summary>
		/// 创建FA_CORP数据层接口。账套表
		/// </summary>
		public static TKFA.IDAL.IFA_CORP CreateFA_CORP()
		{

			string ClassNamespace = Namespace +".FA_CORP";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_CORP)objType;
		}

		/// <summary>
		/// 创建FA_CONTENTS数据层接口。资产目录表
		/// </summary>
		public static TKFA.IDAL.IFA_CONTENTS CreateFA_CONTENTS()
		{

			string ClassNamespace = Namespace +".FA_CONTENTS";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_CONTENTS)objType;
		}

		/// <summary>
		/// 创建FA_CHECKPLAN数据层接口。盘点计划
		/// </summary>
		public static TKFA.IDAL.IFA_CHECKPLAN CreateFA_CHECKPLAN()
		{

			string ClassNamespace = Namespace +".FA_CHECKPLAN";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_CHECKPLAN)objType;
		}

		/// <summary>
		/// 创建FA_CHECK数据层接口。盘点
		/// </summary>
		public static TKFA.IDAL.IFA_CHECK CreateFA_CHECK()
		{

			string ClassNamespace = Namespace +".FA_CHECK";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_CHECK)objType;
		}

		/// <summary>
		/// 创建FA_AUDITPROCESS_PROPERTY数据层接口。审核流程字典
		/// </summary>
		public static TKFA.IDAL.IFA_AUDITPROCESS_PROPERTY CreateFA_AUDITPROCESS_PROPERTY()
		{

			string ClassNamespace = Namespace +".FA_AUDITPROCESS_PROPERTY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_AUDITPROCESS_PROPERTY)objType;
		}

		/// <summary>
		/// 创建FA_AUDITPROCESS数据层接口。审核流程表
		/// </summary>
		public static TKFA.IDAL.IFA_AUDITPROCESS CreateFA_AUDITPROCESS()
		{

			string ClassNamespace = Namespace +".FA_AUDITPROCESS";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_AUDITPROCESS)objType;
		}

		/// <summary>
		/// 创建FA_ASSETSDISPOSAL数据层接口。固定资产处置
		/// </summary>
		public static TKFA.IDAL.IFA_ASSETSDISPOSAL CreateFA_ASSETSDISPOSAL()
		{

			string ClassNamespace = Namespace +".FA_ASSETSDISPOSAL";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_ASSETSDISPOSAL)objType;
		}

		/// <summary>
		/// 创建FA_ASSETCLASS_PROPERTY数据层接口。资产分类
		/// </summary>
		public static TKFA.IDAL.IFA_ASSETCLASS_PROPERTY CreateFA_ASSETCLASS_PROPERTY()
		{

			string ClassNamespace = Namespace +".FA_ASSETCLASS_PROPERTY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_ASSETCLASS_PROPERTY)objType;
		}

		/// <summary>
		/// 创建FA_ASSEES_DYNAMIC数据层接口。资产动态
		/// </summary>
		public static TKFA.IDAL.IFA_ASSEES_DYNAMIC CreateFA_ASSEES_DYNAMIC()
		{

			string ClassNamespace = Namespace +".FA_ASSEES_DYNAMIC";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_ASSEES_DYNAMIC)objType;
		}

		/// <summary>
		/// 创建FA_ANNEXE数据层接口。附件表
		/// </summary>
		public static TKFA.IDAL.IFA_ANNEXE CreateFA_ANNEXE()
		{

			string ClassNamespace = Namespace +".FA_ANNEXE";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_ANNEXE)objType;
		}

		/// <summary>
		/// 创建FA_ALTERATION_PROPERTY数据层接口。资产变动方式字典表
		/// </summary>
		public static TKFA.IDAL.IFA_ALTERATION_PROPERTY CreateFA_ALTERATION_PROPERTY()
		{

			string ClassNamespace = Namespace +".FA_ALTERATION_PROPERTY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_ALTERATION_PROPERTY)objType;
		}

		/// <summary>
		/// 创建FA_ACCESSORY数据层接口。固资卡片附件履历
		/// </summary>
		public static TKFA.IDAL.IFA_ACCESSORY CreateFA_ACCESSORY()
		{

			string ClassNamespace = Namespace +".FA_ACCESSORY";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IFA_ACCESSORY)objType;
		}

		/// <summary>
		/// 创建EMPLOYEE数据层接口。人员表
		/// </summary>
		public static TKFA.IDAL.IEMPLOYEE CreateEMPLOYEE()
		{

            string ClassNamespace = Namespace + ".EMPLOYEE";
			object objType=CreateObject(AssemblyPath,ClassNamespace);
			return (TKFA.IDAL.IEMPLOYEE)objType;
		}
        /// <summary>
        /// 创建FA_PROPERTY_PAGEITEM数据层接口。页面属性参数表
        /// </summary>
        public static TKFA.IDAL.IFA_PROPERTY_PAGEITEM CreateFA_PROPERTY_PAGEITEM()
        {

            string ClassNamespace = Namespace + ".FA_PROPERTY_PAGEITEM";
            object objType = CreateObject(AssemblyPath, ClassNamespace);
            return (TKFA.IDAL.IFA_PROPERTY_PAGEITEM)objType;
        }

        ///// <summary>
        ///// 创建DEPARTMENT数据层接口。部门表
        ///// </summary>
        //public static TKFA.IDAL.IDEPARTMENT CreateDEPARTMENT()
        //{

        //    string ClassNamespace = Namespace +".DEPARTMENT";
        //    object objType=CreateObject(AssemblyPath,ClassNamespace);
        //    return (TKFA.IDAL.IDEPARTMENT)objType;
        //}

}
}